package wectrls.com.wectrlsjavamail.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author chenjian
 * @Package
 * @Description:
 * @date 2019-11-12 10:58
 */
@RestController
public class IndexController {

    @Autowired
    private JavaMailSender javaMailSenderImpl;

    @GetMapping(value = "/index")
    public Object sendMail() {
        SimpleMailMessage simpleMailMessage = new SimpleMailMessage();
        simpleMailMessage.setTo("chenjian2952@163.com");
        simpleMailMessage.setFrom("282762259@qq.com");
        simpleMailMessage.setSubject("邮件测试");
        simpleMailMessage.setText("Java mail test send text success");
        javaMailSenderImpl.send(simpleMailMessage);
        return "ok";
    }
}
